Yacon.container.Table = function(){
	this.recordList     =  new Array();
	this.activeIdx = -1;
	this.activeRecord = null;
};

Yacon.container.Table.Extend(Object,{
	
	/* 创建记录 */
	createRecord: function(){
		
		this.activeIdx ++;		
		this.activeRecord = new Yacon.container.Record();		
		this.recordList.add(this.activeRecord);
		this.activeRecord.setParent(this);
		
		return this.activeRecord;
	},
	
	/* 添加记录 */
	addRecord: function(record){	
		
		this.recordList.add(record);		
		this.activeIdx ++ ;		
		this.activeRecord = record;	
		
	},

	/* 遍历方法 */
	next: function(){
		
		var max =  this.recordList.length;
		
		this.activeIdx ++ ;
		
		if(this.activeIdx >= max){
			this.activeIdx = (max - 1);
			return false;
		}else{
			return true;
		}
		
	},
	
	/* 获取记录数 */
	getRecordCount: function(){
		return this.recordList.length;
	},
	
	/* 获取记录 */
	getRecord: function(){
		
		if(this.activeIdx == -1){
			this.createRecord();
		}
		
		this.activeRecord = this.recordList[this.activeIdx];
		
		return this.recordList[this.activeIdx];
	},
	
	/* 定位-1 */
	beforeFirst: function(){
		this.activeIdx = -1;
	},
	
	/* 获取第一条记录 */
	getFirstRecord:function(){
		this.activeIdx = 0;
		return this.getRecord();
	},
	
	/* 释放缓存 */
	free: function(){
		
		this.beforeFirst();
		while(this.next()){
			this.getRecord().free();
		}
		
		this.recordList.clear();	
	},
	
	/* 获取字段值 */
	getFieldValue: function(fieldName){
		this.getRecord();
		return this.activeRecord.getFieldValue(fieldName);
	},
	
	/* 设置字段值 */
	setFieldValue: function(fieldName,fieldValue){
		this.getRecord();
		this.activeRecord.setFieldValue(fieldName,fieldValue);
	}
	
});